#include "Goal_Obey.h"
#include "Message.h"
#include "Goal_Types.h"
#include "GroupManager.h"

#include "Group.h"
#include "MessageStructs.h"


#include "Goal_ConstructBuilding.h"
#include "Goal_TakePathToRange.h"


Goal_Obey::Goal_Obey(Character* aChar):Goal_Composite<Character>(aChar, goal_obey)
{}



void Goal_Obey::Activate()
{
	m_iStatus = active;
}

int Goal_Obey::Process()
{
	m_iStatus = ProcessSubgoals();
	return m_iStatus;
}

void Goal_Obey::Terminate()
{
	return;
}

bool Goal_Obey::HandleMessage(const Message& msg)
{
	ForwardMessageToFrontMostSubgoal(msg);
	
	switch(msg.Type)
	{
		case Follow_Offset_Path:
			{
				break;
			}

		case BuildBuilding:
			{
				MsgConstructBuilding* building_info = (MsgConstructBuilding*)msg.ExtraInfo;
				AddSubgoal(new Goal_ConstructBuilding(m_pOwner, building_info->BuildingID, building_info->position));
				break;
			}
	}

	return false;
}

